//
//  Helper.h
//  LordApp
//
//  Created by a on 2018/8/27.
//  Copyright © 2018年 a. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

typedef NS_ENUM(NSUInteger, ColorDirection) {
    ColorDirectionLeft,
    ColorDirectionRight,
    ColorDirectionUP,
    ColorDirectiondown,
};

@interface Helper : NSObject

#pragma mark - 设备信息

/// 获取设备信息
+(NSString *_Nullable)getMacAddress;


/// 获取设备类型
+ (NSString*_Nonnull)iphoneType;


/// 是否为模拟器
+ (BOOL)isiphoneSimulator;



#pragma mark - 时间格式化

/// 时间转换date
/// - Parameters:
///   - time: 时间字符串
///   - form: 格式
+(NSDate *_Nullable)timeChangDateWithTimeStr:(NSString *_Nonnull)time witForat:(NSString *_Nullable)form;


/// 根据格式获取当前时间
/// - Parameter format: 格式
+(NSString*_Nullable)getCurrentTimes:(NSString *_Nullable)format;

/// 判定当前时间上午还是中午还是下午还是晚上
/// - Parameter format: 格式
+(NSString*_Nullable)getCurrentQUJIAN;


/// 获取当前月份
+(NSString *_Nullable)getCurrentMonth;

///获取当月带0
+ (NSString *_Nullable)getCurrent0Month;


#pragma mark - 字典、字符串、json转化

/// 转换json字符串
/// - Parameter infoDict: 数据
+ (NSString*_Nonnull)convertToJSONData:(id _Nonnull )infoDict;


/// json转字典
/// - Parameter jsonString: json
+ (NSDictionary *_Nonnull)dictionaryWithJsonString:(NSString *_Nonnull)jsonString;


/// 字典转data
/// - Parameter dicJson: 字典
+ (NSData *_Nonnull)compactFormatDataForDictionary:(NSDictionary *_Nonnull)dicJson;


/// data转字典
/// - Parameter jsonData: data
+ (NSDictionary *_Nonnull)dictionaryForJsonData:(NSData *_Nonnull)jsonData;

//模型转字典
+ (NSDictionary *_Nullable)dicFromObject:(NSObject *_Nullable)object;

//转数组
+ (NSArray *_Nullable)arrayWithObject:(id _Nullable)object;

#pragma mark - 根据内容计算宽高度

/// 获取文本高度
/// - Parameters:
///   - text: 文本
///   - width: 宽度
///   - font: 字体
+ (CGFloat)getLabelHeightWithText:(NSString *_Nullable)text width:(CGFloat)width font: (CGFloat)font;



/// 根据文本获取宽度
/// - Parameters:
///   - text: 文本
///   - height: 高度
///   - font: 字体
+ (CGFloat)getWidthWithText:(NSString *_Nonnull)text height:(CGFloat)height font:(UIFont *_Nonnull)font;

/**
 计算文本高度
 
 @param str         文本内容
 @param width       lab宽度
 @param lineSpacing 行间距(没有行间距就传0)
 @param font        文本字体大小
 
 @return 文本高度
 */
+(CGFloat)getTextHeightWithStr:(NSString *_Nonnull)str withWidth:(CGFloat)width withLineSpacing:(CGFloat)lineSpacing withFont:(UIFont *_Nonnull)font;


#pragma mark - 弹框提示

/// 调用alertcontroller
/// - Parameters:
///   - title: 标题
///   - leftBlock: 左侧按钮点击事件
///   - rightBlock: 右侧按钮点击事件
+(void)createAlertWithTitle:(NSString *_Nonnull)title andLeftBtnClick:(void (^_Nonnull)(void))leftBlock andRightBtnClick:(void (^_Nullable)(void))rightBlock;

/// 调用alertcontroller
/// - Parameters:
///   - title: 标题
///   - leftBlock: 左侧按钮点击事件
///   - leftTitle: 左侧按钮标题
///   - rightBlock: 右侧按钮点击事件
///   - rightTitle: 右侧按钮标题
+(void)createAlertWithTitle:(NSString *_Nonnull)title andLeftBtnClick:(void (^_Nonnull)(void))leftBlock andLeftTitle:(NSString *_Nonnull)leftTitle andRightBtnClick:(void (^_Nonnull)(void))rightBlock  andRightTitle:(NSString *_Nonnull)rightTitle;

/// 调用alertcontroller
/// - Parameters:
///   - title: 标题
///   - rightBlock: 右侧按钮
+(void)createAlertWithTitle:(NSString *_Nonnull)title andBtnClick:(void (^_Nonnull)(void))rightBlock;


#pragma mark - 渐变系列
/// 设置背景渐变
/// @param colors 渐变颜色组
/// @param view 视图
/// @param direction 从哪个方向开始
+ (void)setDiferentColors:(NSArray *_Nullable)colors  WithView:(UIView *_Nullable)view withFlag:(ColorDirection )direction;

#pragma mark - 字符串处理系列

/// 字符串处理
/// - Parameters:
///   - strArray: @[@[文字],@[颜色]，@[字体]]
///   - label: 标签
+(void)setLabelInfo:(NSArray *_Nullable)strArray withLabel:(UILabel *_Nullable)label;


#pragma mark - 检测系列
+ (BOOL)checkTelNumber:(NSString *_Nullable) telNumber;
+ (BOOL)checkPassword:(NSString *_Nullable) password;

//手机号隐藏中间4位
+(NSString *_Nonnull)hidefourNumFromPhone:(NSString *_Nonnull)phone;

//邮箱
+ (BOOL) validateEmail:(NSString *_Nullable)email;


/// 判断归属运营商
/// @param phoneNum 手机号
+ (NSString *_Nullable)getPhoneNumType:(NSString *_Nullable)phoneNum;


/// 展示清单
/// @param title 标题
/// @param array 数组[[@"",@""]]
+(void)showListWithTitle:(NSString *_Nullable)title  withList:(NSArray *_Nullable)array;

//弹出支付界面
+(void)selectPayTypeView:(void (^_Nullable)(NSString * _Nullable type1))type withCancel:(void (^_Nullable)(NSString * _Nullable info))cancel;

//获取城市编码  北京110100
+(NSString *_Nullable)getCityCodeWithName:(NSString * _Nullable)cityName;


/// 弹窗提示
/// @param title 标题
/// @param content 内容
/// @param btnTitle 单一按钮名称
/// @param cancel 按钮点击
+(void)alertShowWithTitle:(NSString *_Nullable)title withContent:(NSString *_Nullable)content withBtnTitle:(NSString *_Nullable)btnTitle withCancel:(void (^_Nullable)(BOOL flag))cancel;


/// 弹窗提示
/// @param title 标题
/// @param content 内容
/// @param btnSureTitle 确认按钮
/// @param btnCancelTitle 取消那妞
/// @param selected 选择第几个
+(void)alertShowWithTitle:(NSString *_Nullable)title withContent:(NSString *_Nullable)content withSureBtnTitle:(NSString *_Nullable)btnSureTitle withCancelBtnTitle:(NSString *_Nullable)btnCancelTitle withSelect:(void (^_Nullable)(NSInteger index))selected;

/// 弹窗提示
/// @param title 标题
/// @param btnSureTitle 确认按钮
/// @param btnCancelTitle 取消那妞
/// @param anwerBlock 填写内容
+(void)alertShowWithTitle:(NSString *_Nullable)title withSureBtnTitle:(NSString *_Nullable)btnSureTitle withCancelBtnTitle:(NSString *_Nullable)btnCancelTitle withAnwer:(void (^_Nullable)(NSString * _Nullable anwer))anwerBlock;

/// 展示vip
/// @param title 标题
/// @param content 内容
+(void)alertShowVipWithTitle:(NSString *_Nullable)title withContent:(NSString *_Nullable)content;

/// copy到临时文件夹
/// - Parameters:
///   - path: 路径
///   - completionBlock: 回调
+(void)getImgPath:(UIImage *_Nullable)image finshBlock:(void(^_Nullable)(int result,NSString * _Nullable path))completionBlock;

+(void)createDir:(NSString *_Nullable)path;
+(void)createFile:(NSString *_Nonnull)path;

/// 展示隐私协议
+(void)privacyAgreementShow;


/// 选择方式
/// @param array 内容数组
/// @param finish 选择几
+(void)alertSelectWithArray:(NSArray *_Nullable)array withFinish:(void (^_Nullable)(NSInteger index,NSString * _Nullable title))finish;


/// 获取随机数
/// @param num 多少位
+(NSString *_Nullable)getRandStr:(int)num;


/// 判断是否在有效期内
/// @param startTime 开始时间
/// @param expireTime 结束时间
+ (BOOL)validateWithStartTime:(NSString *_Nullable)startTime withExpireTime:(NSString *_Nullable)expireTime;


/// 获取唯一识别
+ (NSString *_Nullable)getOnlyStr;

+(NSString *_Nullable)getPath;

#pragma mark 文字处理
+(NSString *_Nullable)addEncode:(NSString *_Nullable)str;
+(NSString *_Nullable)removeEncode:(NSString *_Nullable)str;


/// 视频拼接
/// - Parameters:
///   - videosPathArray: 视频数组
///   - handler: 回调
+(void)mergeAndExportVideos:(NSArray*_Nonnull)videosPathArray WithCompletionHandler:(void (^_Nullable)(NSURL* _Nonnull outPutURL, int code))handler;

+(void)getWANIP; 
@end
